home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / intrvews / tut-code.lha / tut-code / button2 / main.c < prev   
C/C++ Source or Header  |  1992-01-02  |  1KB  |  54 lines

  1. #include <IV-look/kit.h>
  2. #include <InterViews/background.h>
  3. #include <InterViews/image.h>
  4. #include <InterViews/place.h>
  5. #include <InterViews/session.h>
  6. #include <InterViews/style.h>
  7. #include <InterViews/tiff.h>
  8. #include <InterViews/window.h>
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11.  
  12. class App {
  13. public:
  14.     void msg();
  15. };
  16.  
  17. declare(ActionCallback,App)
  18. implement(ActionCallback,App)
  19.  
  20. void App::msg() {
  21.     printf("hi mom!\n");
  22. }
  23.  
  24. int main(int argc, char** argv) {
  25.     Session* session = new Session("Himom", argc, argv);
  26.     if (argc == 1) {
  27.     fprintf(stderr, "Usage: %s <file>\n", argv[0]);
  28.     exit(1);
  29.     }
  30.     Raster* rast = TIFFRaster::load(argv[1]);
  31.     if (rast == nil) {
  32.     fprintf(stderr, "%s: open tiff image %s failed\n", argv[0], argv[1]);
  33.     exit(1);
  34.     }
  35.  
  36.     Style* style = session->style();
  37.     Kit* kit = Kit::instance();
  38.     App* a = new App;
  39.     session->run_window(
  40.     new ApplicationWindow(
  41.         new Background(
  42.         new Margin(
  43.             kit->push_button(
  44.             new Image(rast), style,
  45.             new ActionCallback(App)(a, &App::msg)
  46.             ),
  47.             10.0
  48.         ),
  49.         style->flat()
  50.         )
  51.     )
  52.     );
  53. }
  54.